<?php

include_once 'controller/default.php';
include_once 'model/contact/process.php';
if (isset($_POST)) {
    $contact = new contact();
    if (isset($_POST["accept"])) {
        $insert = $contact->Insert($_POST);
        if ($insert) {
            echo '<script>alert("Thêm Contact thành công.")</script>';
            include 'view/contact/contact_manager.php';
        } else {
            echo '<script>alert("Thêm Contact thất bại.")</script>';
            include 'view/contact/contact_create.php';
        }
    } else if (isset($_POST["update"])) {
        $update = $contact->Update($_POST);
        if ($update) {
            echo '<script>alert("Sửa Contact thành công.")</script>';
            include 'view/contact/contact_manager.php';
        } else {
            echo '<script>alert("Sửa Contact thất bại.")</script>';
            include 'view/contact/contact_update.php';
        }
    }
}
?>
